home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / GraphicViewers / pCD / Source / hpcdtoppm.0.4 / hpcdtoppm.h.ORIG < prev    next >
Text File  |  1993-03-23  |  4KB  |  164 lines

  1. /* hpcdtoppm (Hadmut's pcdtoppm) v0.4
  2. *  Copyright (c) 1992, 1993 by Hadmut Danisch (danisch@ira.uka.de).
  3. *  Permission to use and distribute this software and its
  4. *  documentation for noncommercial use and without fee is hereby granted,
  5. *  provided that the above copyright notice appear in all copies and that
  6. *  both that copyright notice and this permission notice appear in
  7. *  supporting documentation. It is not allowed to sell this software in 
  8. *  any way. This software is not public domain.
  9. */
  10.  
  11.  
  12. #include "config.h"
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include <malloc.h>
  16. #include <sys/types.h>
  17. #include <ctype.h>
  18.  
  19.  
  20.  
  21. /* Format definitions */
  22.  
  23. #define BaseW ((dim)768)
  24. #define BaseH ((dim)512)
  25.  
  26. #define SECSIZE 0x800
  27.  
  28.  
  29. #define SeHead   2
  30. #define L_Head   (1+SeHead)
  31.  
  32. #define SeBase16 18
  33. #define L_Base16 (1+SeBase16)
  34.  
  35. #define SeBase4  72
  36. #define L_Base4  (1+SeBase4)
  37.  
  38. #define SeBase   288
  39. #define L_Base   (1+SeBase)
  40.  
  41.  
  42. #define neutrLum 128
  43. #define neutrCh1 156
  44. #define neutrCh2 137
  45.  
  46.  
  47.  
  48.  
  49.  
  50. /* Structures and definitions */
  51. struct _implane
  52.  {dim  mwidth,mheight,
  53.        iwidth,iheight;
  54.   uBYTE *im,*mp;
  55.  };
  56. typedef struct _implane implane;
  57.  
  58. #define nullplane ((implane *) 0)
  59.  
  60. enum   TURNS  { T_UNSPEC,T_NONE,T_RIGHT,T_LEFT,T_AUTO };
  61. enum   SIZES  { S_UNSPEC,S_Base16,S_Base4,S_Base,S_4Base,S_16Base,S_Over,S_Contact };
  62. enum   OUTFOR { O_UNSPEC,O_PPM,O_PGM,O_YCC,O_PS,O_EPS,O_PSG,O_EPSG };
  63. enum   CORR   { C_UNSPEC,C_LINEAR,C_DARK,C_BRIGHT };
  64.  
  65. enum   ERRORS { E_NONE,E_READ,E_WRITE,E_INTERN,E_ARG,E_OPT,E_MEM,E_HUFF,
  66.                 E_SEQ,E_SEQ1,E_SEQ2,E_SEQ3,E_SEQ4,E_SEQ5,E_SEQ6,E_SEQ7,E_POS,E_IMP,E_OVSKIP,
  67.                 E_TAUTO,E_TCANT };
  68.  
  69.  
  70. /* Macros */
  71. #ifdef DEBUG
  72.  
  73. extern long bufpos;
  74. #define SEEK(x) { if (fseek(fin,((x) * SECSIZE),0)) error(E_READ);\
  75.                   fprintf(stderr,"S-Position %x\n",ftell(fin)); }
  76. #define RPRINT  {fprintf(stderr,"R-Position %x\n",ftell(fin));}
  77. #define READBUF   (bufpos=ftell(fin),fread(sbuffer,sizeof(sbuffer),1,fin))
  78.  
  79. #else
  80.  
  81. #define SEEK(x) { if (fseek(fin,((x) * SECSIZE),0)) error(E_READ);}
  82. #define RPRINT
  83. #define READBUF   fread(sbuffer,sizeof(sbuffer),1,fin)
  84.  
  85. #endif
  86.  
  87.  
  88.  
  89. #define melde(x) {if (do_melde) fprintf(stderr,x);}
  90.  
  91.  
  92. #define EREADBUF {if(READBUF < 1) error(E_READ);}
  93.  
  94. #define SKIP(n)  { if (fseek(fin,(n),1)) error(E_READ);}
  95. #define SKIPr(n) { if (fseek(fin,(n),1)) return(E_READ);}
  96.  
  97.  
  98. #define TRIF(x,u,o,a,b,c) ((x)<(u)? (a) : ( (x)>(o)?(c):(b)  ))
  99. #define xNORM(x) x=TRIF(x,0,255,0,x,255)
  100. #define NORM(x) { if(x<0) x=0; else if (x>255) x=255;}
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113. /* main.c */
  114. extern void         close_all();
  115. extern FILE         *fin,*fout;
  116. extern char         *ppmname,*pcdname;
  117. extern int          do_diff,do_info,do_sharp,do_overskip,monochrome;
  118. extern int          do_melde,do_rep,do_crop;
  119. extern int          flvert,flhori;
  120. extern uBYTE        sbuffer[SECSIZE];
  121. extern enum TURNS   turn;
  122. extern enum SIZES   size;
  123. extern enum OUTFOR  outfor;
  124. extern enum CORR    corrmode;
  125.  
  126. extern float        PAPER_LEFT,PAPER_BOTTOM,PAPER_WIDTH,PAPER_HEIGHT;
  127.  
  128. /* error.c */
  129. extern void         error();
  130.  
  131.  
  132. /* color.c */
  133. extern void         sharpit();
  134. extern void         colconvert();
  135.  
  136. /* tools.c */
  137. extern long         Skip4Base();
  138. extern void         clear();
  139. extern void         halve();
  140. extern void         interpolate();
  141. extern void         planealloc();
  142. extern void         pastein();
  143. extern void         cropit();
  144.  
  145. /* format.c */
  146. extern void         decode();
  147. extern void         readhqt();
  148. extern enum ERRORS  readplain();
  149.  
  150. /* output.c */
  151. extern void         druckeid();
  152. extern void         writepicture();
  153.  
  154. /* ppm.c */
  155. extern void         write_pgm();
  156. extern void         write_ppm();
  157.  
  158. /* postscr.c */
  159. extern void         write_epsgrey();
  160. extern void         write_psgrey();
  161. extern void         write_epsrgb();
  162. extern void         write_psrgb();
  163.  
  164.